package com.test.burnincash.aaahpoppomelo.bean;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.test.burnincash.util_burnin.StringUtil_burnin;

import java.io.Serializable;

public class OrderItem_hpoppomelo implements Serializable {

    private int no;
    private String itemName;
    private int price;
    private int quantity;

    public static OrderItem_hpoppomelo optionItem = new OrderItem_hpoppomelo(0,"",0,0);

    public OrderItem_hpoppomelo(int no, String itemName, int price, int quantity) {
        this.no = no;
        this.itemName = itemName;
        this.price = price;
        this.quantity = quantity;
    }

    public static OrderItem_hpoppomelo parse(String jsonStr){
        Gson gson = new Gson();
        OrderItem_hpoppomelo instance = gson.fromJson(jsonStr,OrderItem_hpoppomelo.class);
        if (instance==null) instance=new OrderItem_hpoppomelo(0,"",0,0);
        return instance;
    }

    public int getNo() {
        return no;
    }

    public String getItemName() {
        return StringUtil_burnin.getSafeString(itemName);
    }

    public int getPrice() {
        return price;
    }

    public int getQuantity() {
        return quantity;
    }

    public int getSum() {
        return getPrice()*getQuantity();
    }

    public void setNo(int no) {
        this.no = no;
    }

    public void setItemName(String itemName) {
        this.itemName = StringUtil_burnin.getSafeString(itemName);
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public JsonElement toJson(){
        return new Gson().toJsonTree(this);
    }
}
